//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml.Drawing
{
    public class Diagram: IOfficeXmlSerializable
    {
        private Ext? _ext;
        private int? _dgmstyle;
        private bool? _autoformat;
        private bool? _reverse;
        private bool? _autolayout;
        private int? _dgmscalex;
        private int? _dgmscaley;
        private string _constrainbounds;
        private RelationTable _relationtable;
        private int? _dgmbasetextscale;
        private int? _dgmfontsize;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(VmlConstants.OfficeNamespace + "diagram")) //\\ from VML
            {
                _ext = c.GetOptionalEnum<Ext>(VmlConstants.VmlNamespace + "ext"); 
                _dgmstyle = c.GetOptionalInteger("dgmstyle");
                _autoformat = c.GetOptionalBoolean("autoformat");
                _reverse = c.GetOptionalBoolean("reverse");
                _autolayout = c.GetOptionalBoolean("autolayout");
                _dgmscalex = c.GetOptionalInteger("dgmscalex");
                _dgmscaley = c.GetOptionalInteger("dgmscaley");
                _dgmfontsize = c.GetOptionalInteger("dgmfontsize");
                _constrainbounds = c.GetOptionalString("constrainbounds");
                _dgmbasetextscale = c.GetOptionalInteger("dgmbasetextscale");
                _relationtable = c.ReadOptionalElement<RelationTable>("relationtable");

            }

        }
         
        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(VmlConstants.OfficeNamespace + "diagram"))
            {
                c.SetOptionalEnum(VmlConstants.VmlNamespace + "ext", _ext);
                c.SetOptionalInteger("dgmstyle", _dgmstyle);
                c.SetOptionalBoolean("autoformat", _autoformat);
                c.SetOptionalBoolean("reverse", _reverse);
                c.SetOptionalBoolean("autolayout", _autolayout);
                c.SetOptionalInteger("dgmscalex", _dgmscalex);
                c.SetOptionalInteger("dgmscaley", _dgmscaley);
                c.SetOptionalInteger("dgmfontsize", _dgmfontsize);
                c.SetOptionalString("constrainbounds", _constrainbounds);
                c.SetOptionalInteger("dgmbasetextscale", _dgmbasetextscale);
                c.WriteOptionalElement(_relationtable);

            }
        }
    }

}
